package com.cloud.bc.controller.pc;

import com.cloud.bc.controller.BaseController;
import com.cloud.bc.model.domain.UserInfo;
import com.cloud.bc.model.entity.BcSingles;
import com.cloud.bc.model.entity.BcUsers;
import com.cloud.bc.service.BcSinglesService;
import com.cloud.bc.service.BcUsersService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//PC设置
@Controller
@AllArgsConstructor
@RequestMapping("center/setup")
public class PcCenterSetupController extends BaseController {
    private final BcUsersService bcUsersService;
    private final BcSinglesService bcSinglesService;

    /**
     * 设置
     */
    @GetMapping("")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "设置-用户中心", "pc/center/setup/index");
        view.addObject("bodyCss", "page_manage page_manage_setup");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        BcUsers userModel = bcUsersService.getById(userInfo.getId());
        BcSingles bcSingles = bcSinglesService.selectOne(new BcSingles().setUserId(userInfo.getId()));
        view.addObject("userModel", userModel);
        view.addObject("bcSingles", bcSingles);
        return view;
    }

    /**
     * 登录密码
     */
    @GetMapping("user_password")
    public ModelAndView userPassword(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "设置-用户中心", "pc/center/setup/user_password");
        view.addObject("bodyCss", "page_manage page_manage_auth");
        return view;
    }

    /**
     * 绑定手机
     */
    @GetMapping("user_mobile")
    public ModelAndView userMobile(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "绑定手机-用户中心", "pc/center/setup/user_mobile");
        view.addObject("bodyCss", "page_manage page_manage_auth");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        BcUsers userModel = bcUsersService.getById(userInfo.getId());
        view.addObject("userModel", userModel);
        return view;
    }

    /**
     * 绑定邮箱
     */
    @GetMapping("user_email")
    public ModelAndView userEmail(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "绑定手机-用户中心", "pc/center/setup/user_email");
        view.addObject("bodyCss", "page_manage page_manage_auth");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        BcUsers userModel = bcUsersService.getById(userInfo.getId());
        view.addObject("userModel", userModel);
        return view;
    }

    /**
     * 黑名单
     */
    @GetMapping("blacklist")
    public ModelAndView blacklist(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request, "黑名单-用户中心", "pc/center/setup/blacklist");
        view.addObject("bodyCss", "page_manage page_manage_setup");
        return view;
    }

}
